<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="app.engine.solucoes.request.beans.*, java.util.*" errorPage="/pages/errorPage.jsp"%>
	<jsp:useBean id="pergunta" class="app.engine.solucoes.request.beans.Pergunta" scope="request" />
	<jsp:useBean id="usuario" class="app.engine.solucoes.request.beans.Usuario" scope="session" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<!-- link type="text/css" rel="stylesheet" href="/estilo/estilo.css" / -->
	<script type="text/javascript" src="/javascript/script.js"></script>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title><%=usuario.getNomeUsuario() != null ? usuario.getNomeUsuario() : ""%> - [Edição de FAQ]</title>
	</head>
<body onload="tringTextArea();">
<%
	if (usuario.getId() == null)
		response.sendRedirect("/");
%>
	<% List<Resposta> respostas = (List<Resposta>) request.getSession().getAttribute("respostas"); %>
	<form name="menu" action="faqtool" method="post">
		<input type="hidden" name="cmd" value="">
		<input type="hidden" name="idPergunta" value="<%=request.getParameter("idPergunta") %>">
		<table border="1" align="center">
			<tr>
				<td>
					<table bgcolor="tan" border="0" align="center" cellpadding="10" cellspacing="0">
						<tr>
							<th colspan="2">Manutenção de FAQs: Atualizar FAQ</th>
						</tr>
						<tr>
							<td><b>Pergunta:</b></td>
							<td><input type="text" name="txtPergunta" size="46"
								value="<jsp:getProperty name="pergunta" property="txtPergunta"/>">
							</td>
						</tr>
						<% 	int i = 0;
							for(Resposta resposta : respostas) { %>
								<%i++;%>
							<tr>
								<td>
									<% if (resposta.getAprovada()) { %>
										<input type="checkbox" name="idResposta:<%= resposta.getId() %>" checked="checked" />
									<%} %>
									<% if (!resposta.getAprovada()) { %>
										<input type="checkbox" name="idResposta:<%= resposta.getId() %>" />
									<%} %>
									<b>Resposta <%= i%>:</b>
								</td>
								<td>
									<textarea name="resposta:<%= resposta.getId() %>" cols="35" rows="5" >
					      				<%= resposta.getTxtResposta() != null ? resposta.getTxtResposta() : "&nbsp" %>
					     			</textarea>
					     		</td>
							</tr>
							
	              		<% } %>
						<tr>
							<td colspan="3" align="center">
								<input type="submit" value="Voltar" onClick="document.menu.cmd.value='update-menu'">
								<input type="submit" value="Salvar" onClick="document.menu.cmd.value='do-update'">
								<input type="submit" value="Nova Resposta" onClick="document.menu.cmd.value='new-answer'">
								<input type="submit" value="Sair" onClick="setCmd('exit')" />
							</td>
						</tr>
						<% if (request.getAttribute("faqtool.msg") != null) { %>
							<tr>
								<td colspan="3" bgcolor="white">
									<font size="-1" color="<%=request.getAttribute("corFonte") != null ? request.getAttribute("corFonte") : "black"%>"> 
										<i><%=request.getAttribute("faqtool.msg")%></i>
									</font>
								</td>
							</tr>
						<%} %>
					</table>
				</td>
			</tr>
		</table>
		<input type="hidden" name="token" value="<%= request.getAttribute("token") %>">
	</form>
</body>
</html>
